package ran.friend.controller.question;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ran.entity.Result;
import ran.entity.TableDataInfo;
import ran.friend.domain.question.dto.QuestionQueryDTO;
import ran.friend.domain.question.vo.QuestionDetailVO;
import ran.friend.service.question.IQuestionService;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ran
 * Date: 2025-11-17
 * Time: 13:18
 */
@RestController
@RequestMapping("/question")
public class QuestionController {
    @Autowired
    private IQuestionService questionService;

    @RequestMapping("/semiLogin/list")
    public TableDataInfo list(QuestionQueryDTO questionQueryDTO) {
        return questionService.list(questionQueryDTO);
    }

    @GetMapping("/detail")
    public Result<QuestionDetailVO> detail(Long questionId) {
        return Result.ok(questionService.detail(questionId));
    }

    // 将题目id的集合存储在Redis中 key -> q:l:   val -> questionId   类型:list
    // 返回给前端一个String类型的id, 因为太长了
    @GetMapping("/preQuestion")
    public Result<String> preQuestion(Long questionId) {
        return Result.ok(questionService.preQuestion(questionId));
    }
    @GetMapping("/nextQuestion")
    public Result<String> nextQuestion(Long questionId) {
        return Result.ok(questionService.nextQuestion(questionId));
    }
}
